/**
 * 文件名：****.java
 * 版权：Copyright Lightkit All Rights Reserved.
 * 描述：*****
 */
package com.lightkits.wms.domain.mainpage;

import com.lightkits.framework.soa.hzero.executor.ServiceExecutor;
import com.lightkits.wms.domain.mainpage.service.OrganizationDomainService;
import com.lightkits.wms.dto.mainpage.QueryOrganizationRequestType;
import com.lightkits.wms.dto.mainpage.QueryOrganizationResponseType;
import com.lightkits.wms.dto.mainpage.model.OrganizationInfoDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * QueryOrganizationExecutor
 *
 * @author menxiao.wu@hand-china.com
 * Created on 2019-02-20 15:05
 */
@Component
public class QueryOrganizationExecutor implements ServiceExecutor<QueryOrganizationRequestType, QueryOrganizationResponseType> {
    private final OrganizationDomainService service;

    @Autowired
    public QueryOrganizationExecutor(OrganizationDomainService service){
        this.service = service;
    }

    @Override
    public QueryOrganizationResponseType service(QueryOrganizationRequestType request) {
        QueryOrganizationResponseType response = new QueryOrganizationResponseType();
        response.setSuccessful(true);

        List<OrganizationInfoDTO> organizationInfoDTOS = service.listOrganizationInfo(request.getLevels());

        response.setOrganizationInfoDTOS(organizationInfoDTOS);
        return response;
    }
}
